;;;Purpose: edit or add TIN points by entities: (1) CIRCLE - uses center point for 3D point information
;;;						(2) POLYLINE - heavy 3D polyline - uses vertex locations for 3D point information
;;;
;;;	Author: Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;	Copyright: 5/5/2014
;;;	   Edited: 5/5/2014
;;;
;;;COMMANDS DEFINED:	EDITPTSBYENT & EPBE (long and short command name)
;;;			ADDPTSBYENT & APBE (long and short command name)
;;;
;;;****************************************************************************
(DEFUN ptsby_error (msg / )
  (IF old_ptsby_osmode
    (SETVAR "osmode" old_ptsby_osmode)
    (SETVAR "osmode" 1285);my default
  )
  (PRINC "\n")
  (PRINC msg)
  (PRINC)
  (IF old_ptsby_error
    (SETQ *error* old_ptsby_error)
    (SETQ *error* NIL)
  )
  (PRINC)
)
;;;****************************************************************************
(DEFUN c:editptsbyent ( / source_ss cnt old_osmode this_ent tinpt_list)
  (SETQ old_ptsby_error *error*)
  (SETQ *error* ptsby_error)
  (SETQ source_ss (SSGET '((-4 . "<OR")(0 . "CIRCLE")(0 . "POLYLINE")(-4 . "OR>"))))
  (SETQ cnt 0)
  (SETQ old_osmode (GETVAR "osmode"))
  (SETVAR "osmode" 0)
  (WHILE (< cnt (SSLENGTH source_ss))
    (COND
      ((AND (WCMATCH (CDR (ASSOC 0 (SETQ this_ent (ENTGET (SETQ this_ename (SSNAME source_ss cnt)))))) "POLYLINE")(EQ (BOOLE 1 (CDR (ASSOC 70 this_ent)) 8) 8))
        (PROGN
          (WHILE (AND (ENTNEXT this_ename)(SETQ this_ent (ENTGET (ENTNEXT this_ename)))(NOT (EQ (CDR (ASSOC 0 this_ent)) "SEQEND")))
            (IF (WCMATCH (CDR (ASSOC 0 this_ent)) "VERTEX")
              (IF tinpt_list (SETQ tinpt_list (APPEND tinpt_list (LIST (CDR (ASSOC 10 this_ent)))))
                (SETQ tinpt_list (LIST (CDR (ASSOC 10 this_ent))))
              )
            )
            (SETQ this_ename (CDR (ASSOC -1 this_ent)))
          )
        ))
      ((WCMATCH (CDR (ASSOC 0 (ENTGET (SSNAME source_ss cnt)))) "CIRCLE")
        (SETQ tinpt_list (LIST (CDR (ASSOC 10 (ENTGET (SSNAME source_ss cnt)))))))
      (T (SETQ tinpt_list NIL))
    )
    (SETQ cnt (1+ cnt))
  )
  (IF tinpt_list
    (FOREACH n tinpt_list
      (IF (EQ (SSLENGTH (SSGET "X" '((0 . "AECC_TIN_SURFACE")))) 1)
        (COMMAND "EDITSURFACEPOINT" (LIST (CAR n)(CADR n)) "" (CADDR n))
        (COMMAND "EDITSURFACEPOINT" "" (LIST (CAR n)(CADR n)) "" (CADDR n))
      )
    )
    (ALERT "No Circles or 3D Polylines were selected! ")
  )
  (SETVAR "osmode" old_osmode)
  (SETQ *error* old_ptsby_error)
)
;;;****************************************************************************
(DEFUN c:epbe () (c:editptsbyent))
;;;****************************************************************************
(DEFUN c:addptsbyent ( / source_ss cnt old_osmode this_ent tinpt_list)
  (SETQ old_ptsby_error *error*)
  (SETQ *error* ptsby_error)
  (SETQ source_ss (SSGET '((-4 . "<OR")(0 . "CIRCLE")(0 . "POLYLINE")(-4 . "OR>"))))
  (SETQ cnt 0)
  (SETQ old_osmode (GETVAR "osmode"))
  (SETVAR "osmode" 0)
  (WHILE (< cnt (SSLENGTH source_ss))
    (COND
      ((AND (WCMATCH (CDR (ASSOC 0 (SETQ this_ent (ENTGET (SETQ this_ename (SSNAME source_ss cnt)))))) "POLYLINE")(EQ (BOOLE 1 (CDR (ASSOC 70 this_ent)) 8) 8))
        (PROGN
          (WHILE (AND (ENTNEXT this_ename)(SETQ this_ent (ENTGET (ENTNEXT this_ename)))(NOT (EQ (CDR (ASSOC 0 this_ent)) "SEQEND")))
            (IF (WCMATCH (CDR (ASSOC 0 this_ent)) "VERTEX")
              (IF tinpt_list (SETQ tinpt_list (APPEND tinpt_list (LIST (CDR (ASSOC 10 this_ent)))))
                (SETQ tinpt_list (LIST (CDR (ASSOC 10 this_ent))))
              )
            )
            (SETQ this_ename (CDR (ASSOC -1 this_ent)))
          )
        ))
      ((WCMATCH (CDR (ASSOC 0 (ENTGET (SSNAME source_ss cnt)))) "CIRCLE")
        (SETQ tinpt_list (LIST (CDR (ASSOC 10 (ENTGET (SSNAME source_ss cnt)))))))
      (T (SETQ tinpt_list NIL))
    )
    (SETQ cnt (1+ cnt))
  )
  (IF tinpt_list
    (FOREACH n tinpt_list
      (IF (EQ (SSLENGTH (SSGET "X" '((0 . "AECC_TIN_SURFACE")))) 1)
        (COMMAND "ADDSURFACEPOINT" (LIST (CAR n)(CADR n)) (CADDR n) "")
        (COMMAND "ADDSURFACEPOINT" "" (LIST (CAR n)(CADR n)) (CADDR n) "")
      )
    )
    (ALERT "No Circles or 3D Polylines were selected! ")
  )
  (SETVAR "osmode" old_osmode)
  (SETQ *error* old_ptsby_error)
)
;;;****************************************************************************
(DEFUN c:apbe () (c:addptsbyent))